package com.wannengbang.cloudleader.performance;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wannengbang.cloudleader.R;
import com.wannengbang.cloudleader.base.BaseActivity;
import com.wannengbang.cloudleader.base.DataCallBack;
import com.wannengbang.cloudleader.bean.StatisticsTypeBean;
import com.wannengbang.cloudleader.homepage.TransactionQueryActivity;
import com.wannengbang.cloudleader.performance.model.IPerformanceModel;
import com.wannengbang.cloudleader.performance.model.PerformanceModelImpl;
import com.wannengbang.cloudleader.utils.NumberFormatUtils;
import com.wannengbang.cloudleader.widget.AppTitleBar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class PerformanceTypeActivity extends BaseActivity {


    @BindView(R.id.title_bar)
    AppTitleBar titleBar;
    @BindView(R.id.tv_trans_type1011)
    TextView tvTransType1011;
    @BindView(R.id.ll_trans_type1011)
    LinearLayout llTransType1011;
    @BindView(R.id.tv_trans_type1171)
    TextView tvTransType1171;
    @BindView(R.id.ll_trans_type1171)
    LinearLayout llTransType1171;
    @BindView(R.id.tv_trans_type1191)
    TextView tvTransType1191;
    @BindView(R.id.ll_trans_type1191)
    LinearLayout llTransType1191;
    @BindView(R.id.tv_trans_type1181)
    TextView tvTransType1181;
    @BindView(R.id.ll_trans_type1181)
    LinearLayout llTransType1181;
    @BindView(R.id.tv_trans_type1681)
    TextView tvTransType1681;
    @BindView(R.id.ll_trans_type1681)
    LinearLayout llTransType1681;
    @BindView(R.id.tv_trans_type1691)
    TextView tvTransType1691;
    @BindView(R.id.ll_trans_type1691)
    LinearLayout llTransType1691;
    @BindView(R.id.tv_trans_type1391)
    TextView tvTransType1391;
    @BindView(R.id.ll_trans_type1391)
    LinearLayout llTransType1391;
    @BindView(R.id.tv_trans_type1381)
    TextView tvTransType1381;
    @BindView(R.id.ll_trans_type1381)
    LinearLayout llTransType1381;
    @BindView(R.id.tv_trans_type1581)
    TextView tvTransType1581;
    @BindView(R.id.ll_trans_type1581)
    LinearLayout llTransType1581;
    @BindView(R.id.tv_trans_type1591)
    TextView tvTransType1591;
    @BindView(R.id.ll_trans_type1591)
    LinearLayout llTransType1591;
    @BindView(R.id.tv_trans_type1291)
    TextView tvTransType1291;
    @BindView(R.id.ll_trans_type1291)
    LinearLayout llTransType1291;
    @BindView(R.id.tv_trans_type1281)
    TextView tvTransType1281;
    @BindView(R.id.ll_trans_type1281)
    LinearLayout llTransType1281;
    @BindView(R.id.tv_trans_type1481)
    TextView tvTransType1481;
    @BindView(R.id.ll_trans_type1481)
    LinearLayout llTransType1481;
    @BindView(R.id.tv_trans_type1491)
    TextView tvTransType1491;
    @BindView(R.id.ll_trans_type1491)
    LinearLayout llTransType1491;
    @BindView(R.id.tv_trans_type9999)
    TextView tvTransType9999;
    @BindView(R.id.ll_trans_type9999)
    LinearLayout llTransType9999;
    private IPerformanceModel performanceModel;
    private String cycleType;
    private String param;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_performance_type);
        ButterKnife.bind(this);
        initView();
        requestTradeMoneyCount();
    }

    private void initView() {
        cycleType = getIntent().getStringExtra("cycleType");
        param = getIntent().getStringExtra("param");
        performanceModel = new PerformanceModelImpl();

    }

    public void requestTradeMoneyCount() {
        String paramValue = "";
        if (!TextUtils.isEmpty(param)) {
            paramValue = param.replace(".", "-");
        }
        performanceModel.requestTradeMoneyCount(cycleType, paramValue, new DataCallBack<StatisticsTypeBean>() {
            @Override
            public void onSuccessful(StatisticsTypeBean bean) {
                String trans_type1171 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1171()) / 100);
                String trans_type1011 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1011()) / 100);
                String trans_type1191 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1191()) / 100);
                String trans_type1181 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1181()) / 100);
                String trans_type1681 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1681()) / 100);
                String trans_type1691 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1691()) / 100);
                String trans_type1391 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1391()) / 100);
                String trans_type1381 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1381()) / 100);
                String trans_type1581 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1581()) / 100);
                String trans_type1591 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1591()) / 100);
                String trans_type1291 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1291()) / 100);
                String trans_type1281 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1281()) / 100);
                String trans_type1481 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1481()) / 100);
                String trans_type1491 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type1491()) / 100);
                String trans_type9999 = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(bean.getData().getTrans_type9999()) / 100);
                tvTransType1171.setText(trans_type1171);
                tvTransType1011.setText(trans_type1011);
                tvTransType1191.setText(trans_type1191);
                tvTransType1181.setText(trans_type1181);
                tvTransType1681.setText(trans_type1681);
                tvTransType1691.setText(trans_type1691);
                tvTransType1391.setText(trans_type1391);
                tvTransType1381.setText(trans_type1381);
                tvTransType1581.setText(trans_type1581);
                tvTransType1591.setText(trans_type1591);
                tvTransType1291.setText(trans_type1291);
                tvTransType1281.setText(trans_type1281);
                tvTransType1481.setText(trans_type1481);
                tvTransType1491.setText(trans_type1491);
                tvTransType9999.setText(trans_type9999);
            }

            @Override
            public void onFailed(String msg, String code) {

            }
        });
    }

    @OnClick({R.id.ll_trans_type9999, R.id.ll_trans_type1011, R.id.ll_trans_type1171, R.id.ll_trans_type1191, R.id.ll_trans_type1181, R.id.ll_trans_type1681, R.id.ll_trans_type1691, R.id.ll_trans_type1391, R.id.ll_trans_type1381, R.id.ll_trans_type1581, R.id.ll_trans_type1591, R.id.ll_trans_type1291, R.id.ll_trans_type1281, R.id.ll_trans_type1481, R.id.ll_trans_type1491})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_trans_type9999:
                Intent intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "9999");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1011:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1011");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1171:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1171");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1191:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1191");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1181:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1181");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1681:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1681");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1691:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1691");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1391:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1391");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1381:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1381");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1581:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1581");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1591:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1591");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1291:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1291");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1281:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1281");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1481:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1481");
                startActivity(intent);
                break;
            case R.id.ll_trans_type1491:
                intent = new Intent(mActivity, TransactionQueryActivity.class);
                intent.putExtra("cycleType", cycleType);
                intent.putExtra("param", param);
                intent.putExtra("trans_type", "1491");
                startActivity(intent);
                break;
        }
    }
}
